<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:pe="http://primefaces.org/ui/extensions"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>#{bundle.education}</title>
        <link href="./resources/css/default.css" rel="stylesheet" type="text/css" />
    </h:head>
    <h:body>
        <ui:composition>
        <h:form >
           <script type="text/javascript">  
                function handleSaveRequestEducation(xhr, status, args) {  
                    if(args.validationFailed || !args.success) {  
                        jQuery('#dialog').effect("shake", { times:3 }, 100);  
                    } else {  
                        dlgEducation.hide();  
                    }  
                }
                
                function handleDeleteRequestEducation(xhr, status, args) {  
                    if(args.validationFailed || !args.success) {  
                        jQuery('#dialog').effect("shake", { times:3 }, 100);  
                    } else {  
                        dlgDelEdu.hide();  
                    }  
                }
                
                function textOnKeyPress(e) {
                    var code = (e.keyCode ? e.keyCode : e.which);
                    if(code==13) {
                        cmdSearchEdu.jq.click();
                        e.returnValue=false;
                        e.cancel =true;
                        e.preventDefault();
                    }
                }
                
                function componenKeyPress(e) {
                    var code = (e.keyCode ? e.keyCode : e.which);
                    if(code==13) {
                        submitEdu.jq.click();
                        e.preventDefault();
                    }
                }
                
            </script>  

            <p:toolbar>
                <p:toolbarGroup align="left">
                    <p:commandButton value="#{bundle.btnNew}" icon="ui-icon-document"
                                     action="#{educationBean.newData()}" rendered="#{menuBean.cekButtonAccess(10,'INS;')}"
                                     oncomplete="dlgEducation.show()" process="@this"    
                                     update=":#{utilityBean.findClientId('displayEducation')}"> 
                         <pe:resetEditableValues for="displayEducation" />                          
                    </p:commandButton>

                    <p:commandButton value="#{bundle.btnOpen}" action="#{educationBean.openData()}" oncomplete="dlgEducation.show()" rendered="#{menuBean.cekButtonAccess(10,'OPN;')}"
                                     icon="ui-icon-disk" 
                                     update=":#{utilityBean.findClientId('displayEducation')}" > 
                    </p:commandButton>

                    <p:commandButton value="#{bundle.btnDelete}" icon="ui-icon-trash" onclick="dlgDelEdu.show()" 
				     rendered="#{menuBean.cekButtonAccess(10,'DEL;')}" />
                   <!-- <h:panelGroup>
                        <p:commandButton value="#{bundle.btnSearch}" icon="ui-icon-search" 
                                         onclick="dlgSearchEducation.show()"/> 
                    </h:panelGroup>
                    -->
                </p:toolbarGroup>
             <!--   <p:toolbarGroup align="right">
                    <h:panelGrid columns="3" cellpadding="0" cellspacing="0">  
                        <p:inputText id="eduserach" value="#{educationBean.filter}" onkeypress="textOnKeyPress(event)" />  
                        <p:watermark for="eduserach" value="#{bundle.wtmSearch}" />  
                        
                        <p:commandButton widgetVar="cmdSearchEdu" icon="ui-icon-search" update="dtEducations" 
                                         actionListener="#{educationBean.search()}" /> 
                    </h:panelGrid>  
                </p:toolbarGroup>
             -->
            </p:toolbar>
            <br />
            
            <p:dataTable var="edu" value="#{educationBean.educations}" id="dtEducations"
                         selection="#{educationBean.selectedData}" selectionMode="single" resizableColumns="true"
                         rowIndexVar="noUrut"    rowKey="#{edu.educationId}" 
                         paginator="false" rows="10" paginatorPosition="bottom" 
                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                         rowsPerPageTemplate="5,10,15,30">
                 <p:column style="width: 10px">
                    <f:facet name="header">No.</f:facet>
                    <h:outputText value="#{noUrut+1}" />
                 </p:column>
                <p:column style="width:200px" sortBy="#{edu.educationName}">
                    <f:facet name="header">#{bundle.globalName}</f:facet>
                    <h:outputText value="#{edu.educationName}" />
                </p:column>
                <p:column style="width:auto" rendered="false" >
                    <f:facet name="header">ID</f:facet>
                    <h:outputText value="#{edu.educationId}" />
                </p:column>
            </p:dataTable>
          
            <p:confirmDialog message="#{bundle.confirmDelete}" appendToBody="true" 
                             header="#{bundle.confirmDeleteHeader}" severity="alert" widgetVar="dlgDelEdu">
                <h:panelGrid cellspacing="0" cellpadding="0" styleClass="pComBtnD">
                    <f:facet name="footer">
                        <p:commandButton value="#{bundle.btnYes}" update="dtEducations" process="@this"
                             oncomplete="handleDeleteRequestEducation(xhr, status, args)"  
                             actionListener="#{educationBean.delete()}" />  
                        <p:commandButton value="#{bundle.btnCancel}" onclick="dlgDelEdu.hide()" type="button" /> 
                    </f:facet>
                </h:panelGrid>
            </p:confirmDialog>
        
            <p:dialog header="#{bundle.btnSearch}" widgetVar="dlgSearchEducation" closable="true" dynamic="true" modal="true" appendToBody="true">
                
                <h:panelGrid columns="2" styleClass="addELIT">
                    <h:outputLabel style="padding: 0 15px 0 0" value="#{bundle.globalName} :" />
                    <p:inputText value="#{educationBean.filter}" size="25" />
                </h:panelGrid> 
                
                <h:panelGrid cellpadding="0" styleClass="pComBtnSTDR">
                    <f:facet name="footer">  
                        <p:commandButton value="#{bundle.btnSearch}" icon="ui-icon-search" actionListener="#{educationBean.search()}"
                                         update="dtEducations" />  
                        <p:commandButton value="#{bundle.btnClose}" oncomplete="dlgSearchEducation.hide()" icon="ui-icon-document"/>
                    </f:facet>
                </h:panelGrid>
            </p:dialog>
            
        </h:form>
            <p:dialog header="#{bundle.education}" widgetVar="dlgEducation" closable="true" dynamic="true" modal="true" appendToBody="true">
                <p:ajax event="close" listener="#{educationBean.handleClose}" immediate="true"/>
                <h:form>
                <p:focus />
                <h:panelGrid id="displayEducation" columns="2" styleClass="addELIT">
                    <h:outputLabel style="padding: 0 15px 0 0" value="#{bundle.globalName} :" />
                    <h:panelGroup>                          
                        <p:inputText rendered="#{educationBean.insertedData!=null}" value="#{educationBean.insertedData.educationName}" 
                                     required="true" label="#{bundle.globalName}" size="25" onkeydown="componenKeyPress(event)"/>
                    </h:panelGroup>
                </h:panelGrid> 
                
                <h:panelGrid cellpadding="0" styleClass="pComBtnSTDR">
                    <f:facet name="footer">  
                        <p:commandButton value="#{bundle.btnSave}" icon="ui-icon-disk" actionListener="#{educationBean.save()}" rendered="#{menuBean.cekButtonAccess(10,'UPD;')}"
                                         update=":#{utilityBean.findClientId('dtEducations')}" widgetVar="submitEdu"                
                                         oncomplete="handleSaveRequestEducation(xhr, status, args)"/>  
                        <p:commandButton  immediate="true" value="#{bundle.btnClose}" oncomplete="dlgEducation.hide()" icon="ui-icon-document"/>
                    </f:facet>
                </h:panelGrid>
                </h:form>
            </p:dialog>
        
        </ui:composition>        
    </h:body>
</html>
